<?php

// With third Varibale

$a = 5;
$b = 6;

echo "\n\nBefore a=$a , b=$b";

$tmp = $a;
$a   = $b;
$b   = $tmp;

echo "\n\nAfter a=$a , b=$b";
echo "\n\n========================\n\n";

// Without third Varibale (1)

$a = 5;
$b = 6;

echo "\n\nBefore a=$a , b=$b";

$a   = $a + $b;// 5 + 6 = 11
$b   = $a - $b;// 11 - 6 = 5
$a   = $a - $b;// 11 - 5 = 6

echo "\n\nAfter a=$a , b=$b";
echo "\n\n========================\n\n";

// Without third Varibale (2)

$a = 5;
$b = 6;

echo "\n\nBefore a=$a , b=$b";

$a   = $a * $b;// 5 * 6 = 30
$b   = $a / $b;// 30 / 6 = 5
$a   = $a / $b;// 30 / 5 = 6

echo "\n\nAfter a=$a , b=$b";
echo "\n\n========================\n\n";

// Without third Varibale (3)

$a = 5;
$b = 6;

echo "\n\nBefore a=$a , b=$b";

$a   = $a ^ $b;// 101 ^ 110 = 011
$b   = $a ^ $b;// 011 ^ 110 = 101 => 5
$a   = $a ^ $b;// 011 ^ 101 = 110 => 6

echo "\n\nAfter a=$a , b=$b";
echo "\n\n========================\n\n";
